﻿<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title> CSS3 3D旋转立方体 </title>
</head>

<style type="text/css">
  body {
    font-size: 12px;
    color: white;
    background-color: black;
    background-repeat: no-repeat;
    background-image: -webkit-gradient(radial, 50% 500, 1, 50% 500, 400, from(rgba(255, 255, 255, 0.3)), to(rgba(255, 255, 255, 0)));
  }

  #container {
    width: 100%;
    height: 700px;
    -webkit-perspective: 800; /* For compatibility with iPhone 3.0, we leave off the units here */
    -webkit-perspective-origin: 50% 225px;
  }

  #stage {
    width: 100%;
    height: 100%;
    -webkit-transition: -webkit-transform 2s;
    -webkit-transform-style: preserve-3d;
  }
  #shape {
    position: relative;
    top: 160px;
    height: 200px;
    width: 200px;
    margin: 0 auto;
    -webkit-transform-style: preserve-3d;
  }

  .plane {
    position: absolute;
    left:0;
    top:0;
    height: 200px;
    width: 200px;
    text-align: center;
    border-radius: 12px;
    box-sizing: border-box;
    font-size: 124pt;
    color: black;
    border: 1px solid white;
    backface-visibility: hidden;
    transition: transform 2s, opacity 2s;
    background-color: rgba(255, 255, 255, 0.6);
  }

  #shape.backfaces .plane {
    backface-visibility: visible;
  }

  #shape {
    animation: spin 8s infinite linear;
  }

  @keyframes spin {
    from {
      transform: rotateY(0); 
    }
    to   {
      transform: rotateY(-360deg); 
    }
  }

  .cube > .one {
    opacity: 0.5;
    transform: scale3d(1.2, 1.2, 1.2) rotateX(90deg) translateZ(100px);
  }

  .cube > .two {
    opacity: 0.5;
    transform: scale3d(1.2, 1.2, 1.2) translateZ(100px);
  }

  .cube > .three {
    opacity: 0.5;
    transform: scale3d(1.2, 1.2, 1.2) rotateY(90deg) translateZ(100px);
  }

  .cube > .four {
    opacity: 0.5;
    transform: scale3d(1.2, 1.2, 1.2) rotateY(180deg) translateZ(100px);
  }

  .cube > .five {
    opacity: 0.5;
    transform: scale3d(1.2, 1.2, 1.2) rotateY(-90deg) translateZ(100px);
  }

  .cube > .six {
    opacity: 0.5;
    transform: scale3d(1.2, 1.2, 1.2) rotateX(-90deg) translateZ(100px) rotate(180deg);
  }

  .cube > .seven {
    transform: scale3d(0.8, 0.8, 0.8) rotateX(90deg) translateZ(100px) rotate(180deg);
  }

  .cube > .eight {
    transform: scale3d(0.8, 0.8, 0.8) translateZ(100px);
  }

  .cube > .nine {
    transform: scale3d(0.8, 0.8, 0.8) rotateY(90deg) translateZ(100px);
  }

  .cube > .ten {
    transform: scale3d(0.8, 0.8, 0.8) rotateY(180deg) translateZ(100px);
  }

  .cube > .eleven {
    transform: scale3d(0.8, 0.8, 0.8) rotateY(-90deg) translateZ(100px);
  }

  .cube > .twelve {
    transform: scale3d(0.8, 0.8, 0.8) rotateX(-90deg) translateZ(100px);
  }

</style>
<body >
<div id="container">
  <div id="stage">
    <div id="shape" class="cube backfaces">
      <div class="plane one">1</div>
      <div class="plane two">2</div>
      <div class="plane three">3</div>
      <div class="plane four">4</div>
      <div class="plane five">5</div>
      <div class="plane six">6</div>
      <div class="plane seven">7</div>
      <div class="plane eight">8</div>
      <div class="plane nine">9</div>
      <div class="plane ten">10</div>
      <div class="plane eleven">11</div>
      <div class="plane twelve">12</div>
    </div>
  </div>
</div>
</body>
</html>